import requests
import execjs
import time
import hashlib

import hmac

msg = '{"stockId":"82673841481793","_":"1724079854602"}'

data = hmac.new(bytes('quote_web', encoding='utf-8'), bytes(msg, encoding='utf-8'), hashlib.sha256).hexdigest()

# //'98d6ea4830'
print(data[0:10])

#
# timestamp = time.time()
# stockId = '82673841481793'
#
# jscode = open("./main.js", "r", encoding='utf-8').read()
# token = execjs.compile(jscode).call('getToken', stockId, timestamp)
#
# futu_x_csrf_token = 'j2uwEmxdIsJxjSMzi-Qz_OZS'
#
# headers = {
#     "Accept": "application/json, text/plain, */*",
#     "Accept-Language": "zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6",
#     "Cache-Control": "no-cache",
#     "Connection": "keep-alive",
#     "Pragma": "no-cache",
#     "Referer": "https://www.futunn.com/stock/3382-JP?global_content=%7B%22promote_id%22%3A13766,%22sub_promote_id%22%3A3%7D",
#     "Sec-Fetch-Dest": "empty",
#     "Sec-Fetch-Mode": "cors",
#     "Sec-Fetch-Site": "same-origin",
#     "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.36 Edg/127.0.0.0",
#     "futu-x-csrf-token": futu_x_csrf_token,
#     "quote-token": token,
#     "sec-ch-ua": "\"Not)A;Brand\";v=\"99\", \"Microsoft Edge\";v=\"127\", \"Chromium\";v=\"127\"",
#     "sec-ch-ua-mobile": "?0",
#     "sec-ch-ua-platform": "\"Windows\""
# }
#
# url = "https://www.futunn.com/quote-api/quote-v2/get-kline"
#
# params = {
#     "stockId": stockId,
#     "marketType": "25",
#     "type": "2",
#     "marketCode": "830",
#     "instrumentType": "3",
#     "subInstrumentType": "0",
#     "_": timestamp
# }
#
# response = requests.get(url, headers=headers, params=params)
#
# print(response.json())
# print(response)
